Extracted rendering code to a new class.