cleanning up the js code