fixed after refactoring