Reworking logic so is more DI friendly