Fix calculating rows