Fix bug in refactoring