Implementation refactored for render_tag as per @ojii

Signed-off-by: Martin Koistinen <mkoistinen@gmail.com>