original code plus while