Refactor collatz into a class