adding optional close button functionality