refactors javascriptfor more conciseness