added bash trap code for implementation