cnipr code refactoring