First working version, all tests pass