hmm we should try to factorize the bottom half here looks like imap