Bug fix for deleting all elements