no need to loop three times for the lines - cache the text and insert it repeatedly later