made the loading and closing modular