Fixed addEventsToGui

made some improvements in this method