Refactor a bit
More refactoring here