Did a bit of refactoring