corrected some errors during refactoring