Updated loading screen logic