Fix when() clause