refactoring, fix bug