Removed duplicate logic and improved error handling in file request parts.