Refactored sign up script into javascript file