Refactor modal.js