final analysis and cleaning script