Fixed code to gui