Refactored password hash check.