cleaned up some code in convert