add trapping functionality to traps