Fix bug with array.slice