trap calls only the most recently trapped function