moved imap handling into imap object