Refactor js

Blending functions when clicking submit button