added error handling for parsing