Adding error handling for empty values