add line totals and refactor reicpe.js