Some refactoring to clarify to make testing easier hopefully