Refactored tidy (all tests passes)