fix remove_delayed function