The federal government wasted approximately $41 million in the past three and a half years by flying illegal immigrants back to their home countries on expensive but largely empty charter flights, according to a report by the Department of Homeland Security inspector general's office.

Poor planning and management resulted in the Immigration and Customs Enforcement (ICE) failing to fill seats effectively or document enough information on the detainees, the report said.

"ICE Air operated charter flights with empty seats and could have realized cost savings of up to $41.1 million upon determining optimum flight capacity," according to the inspector general, The Washington Post initially reported.

The report found that from October 1, 2010 through March 31, 2014, ICE Air spent $464 million on charter flights. Each flight costs about $8,419 on average, regardless of the number of people on the flight. The agency maintains a fleet of eight airplanes which can each carry up to 135 detainees.

The agency spent about $116 million on flights that had 20 percent of seats unoccupied, including $12 million on flights that had about 60 percent unused space. More than one-third of the nearly 7,500 flights reviewed were less than 80 percent full.

Nearly 23,000 detainees were picked up or dropped off at locations not on the charter flight route. "Specifically, there were 54 detainees recorded as removed to Nicaragua for one mission that included stops only in Louisiana, Texas and Guatemala," the report found.

As for the ineffective and inaccurate documentation of detainee information, ICE failed to report whether 20,798 detainees had a criminal background, leaving the "Criminality" data field blank or filled with non-logical entries such as "#Ref!".

The data field for the sex of a detainee also contained numerous nonsensical entries, as did the data field used to identify whether a detainee was a gang member, with the latter being left blank for 155,966 detainees.

The inspector general recommended that ICE implement "formal policies and procedures for its air transportation program" and "ensure adequate staffing, complete and reliable program data, and perform an analysis of operations to identify factors affecting efficiency."

Inspector General John Roth commented in a statement, "ICE officials must ensure that management and staff use their program's resources effectively. ICE has started taking action to implement our recommendations, which, once implemented, should provide improvements to the program and assurances that taxpayer funds are being spent efficiently."