fixing bug after refactoring