Prepare parse function for error handling