Fix bug in imap for copy