refactor client side js