Refactored sql query and made it use the primary key instead of email when searching on users