Refactored and divided codes