ported calculation of map