Solving p17
Refactoring p17