Refactor email controler