generalized ipis
more refactoring