refactored to better test the client code