Refactoring to probl17 code