refactoring some function