Move logic into convert.py