kind of working. moving logic from jinja to python next.