added error handling context manager, refactored initialization usage