Added while loop and built exit functionality