updated code for Gui