js code clean up