build the min and map