First draft of while code