Encapsulate rendering code in renderer function.