fixing logic bugs in trash handling