If the 5% commission is taken from any winnings, then why do you wish to add it to losses? Also, why are you deducting 5% from losses?
If I understand you correctly, it seems the logic should be:
1. Place bet of amount X. Subtract bet amount from "pocket," i.e., your total.
2. If the bet loses, do nothing. The total, having already been reduced, stays the same.
3. If the bet wins, add X (your original bet) back to the total, then add .95X (95% of the winnings) to the total.
Repeat steps 1-3.