Complete function for preloader