rewritten swap case