corrected a bug in mapcentroid function