javascript break loop inside switch