merged it all into one function, plus 30% more rows!
updated comments and pre tag