fixed issue #1, reduced switches from 4 to 3