added loader and show and close loader functions