cleaned up check mail function