Fixed Algorithm and Variables

Algorithm should now work properly for any amount of columns and
computes the result corectly.

Renamed Variables for better readability.