Refactoring JS for form default values