Added event handeling to gui