refactor login validation