some code clean-up in delete functionality