modified to pass unit test