Refactor trigger.py to use a class