Removing duplicated render code to a common inline function