Refactor UART example