Bug after refactoring