refactor imap fetch