fixed bug in the deletion mechanism