Refactor modal opening and show spinner animation when loading