refactored ui code to be completely created in javascript