moved gui code to a gui method