Formula 1st rewrite

Added functions MIN, MAX, SUM and AVERAGE