working version with contour moments