refactored some code base