Major refactoring: added ideal I into consideration