-java script refactor
-added front-end validation