Fix a bug in last refactor