Although global variables are problematic in many software projects, here they are necessary and appropriate. The pictures and slideIndex variables must be global because otherwise there is no other way to share their state between different invocations of the Screen.Initialize and NextButton handlers. Using global variables or component properties (components are also global) to communicate state information between event handler invocations is a common pattern in event-based programming in App Inventor. They effectively act like registers in a state-based abstract machine.