COnverted lookup to while