made remove() shrink the array when necessary