move analysis logic out of html