refactoring some code.