restoring previous event logic
js styling & removing unneeded code