added thread safety to GUI