wrote converting logic