write main function for bi-directional converter