Capital Gains

I’m structuring a deal right now where, after realtor fees and capital gains taxes, I will walk away with only about $22k out of a $50k deal. Question for the more experienced investors: are there ways to save some of this money through legal entities or land trusts, or any other methods to keep more of this money in my pocket? Any help is greatly appreciated.