factor out render