changed to switch structure