Got rid of the scan in calculating reccurence relation matrix