fixed code to match tests