Fixed Error Handling and File Fetching Method