Fix a bug - tests pass