Modified code to allow passing in a custom renderer.