Improved mail checking and implemented duplicate checking