refactoring some part