finished conversion code