Fixed the iOS main loop