separate out long-term gains, some code simplification