removing debug output
cleaning up
comments
changing matrix traversing direction for optimization