Created functions and converted email to use functions and sanitize input