Setup while loop and validating

Setup while loop and validating