Partial refactoring to be more extendable