move email check to server side