Start of unified conversion function