optimizing inner product calc