login validation refactored