use more references instead of copying arrays