Refactor recommendation generation and formatting into two methods