working on trap functionality