Refactored to make project more testable