IRR + some refactoring