Refactored some code in parts controller.