Refactored JavaScript for Sign In/Up