removed some '-1' according to the change in array dimensions
hopefully get rid of last '-1' stuff