fixed js run time error

added prevent default
removed setTimeout functions