added loading/splash screen into a function