Pass tests and linted - needs refactoring