only calculate map once