Error handling modified and indentation changed