trap works correctly now