Refactored to utilise events instead of local functions
Added modal.js as dependency