trap function need to test.