Modularize conversion code