fixed bug when multiple states point to a state that will be deleted