Refactoring 2

Now it works and can compile