all tests pass - code could be cleaner