fixing refactoring bugs