Rather than building up a return string, it would be neater if you created a view for this.