Uses some method istead of manually loop trough array
Speed up calculation by using two dimensional arrays
Merge branch 'refactor'