refactor modal js