Completed the HEP tutorial with refactored code