bug fixes for refactoring