fixing javascript full page refresh