moved build logic to render function