woring version. All tests pass