use imap-parser & better error handling