refactored, log on the gui