Refactored code for global functions and boot box