Changing the processing loop and adding helper methods