dividing the GUI code into functions