added global events when modal is opened and closed