First attempt at first version, all tests pass