added rejecting code to while loop.