Few simplifications using Array in the loop instead of Matrix'