factor out individual functions, generate report