fixed so that it works after refactoring