Fix email logic