splitting main UI code and serial code