Refactor modals into template