Corrected error while removing elements.