updated replace to use render_state