edit: pass local variable to trap function