Switched conversion code to python