fix duplicate sent mail
complete refactor