Fixed char class logic. Used swap to make it easier to read.