refactor: error handling