By outsourcing the functions to a separate company. That way they aren't firing an American worker and replacing him with an H-1B. They are firing the worker because the position isn't there anymore. It's with the outsourcing company, who can hire whoever they want.
The need to hire Americans, set the H-1b quotas to zero. Kill this damn thing.