fixing array slice bug