refactor some code base and extract class for utils