merged Main with analysis