refactor client JS code into module and cleanup
todo list