Refactoring modal function
Refactoring javascript functions for loading the modal on page and client