significant improvement to login validation