fixing array arithmetic order