reworked the modal window functionality