Fix bug after refactoring