used a switch for performance