fixes variable shadowing bug in delete