Bug fix after refactoring