improvement of deletion algorithm