Added switch code. Untested.