fixed bug where row in matrix was recalculated unncessarily