cleaning up the modal JS to fix bug