fixes bugs after refactoring