Fixed up the logic in the gui a bit