Code review: use splice to remove element