fixed minor bugs after refactoring