use im_count to keep track of imaginary contribution to sign