Added switch logic