Refactored trap to match ERR as well - removed output function