fix auto refactoring bugs