use splice to remove some elements from an array