correct row calculation