Helper function to loop through all parts