Refactored - all unit tests pass