refactored login form validation