wrong second argument  given to array.splice