fixed some redundancies in JS file