Improve login validation