Added learning switch code