Adding logic to GUI