Used Loops to correct validation

used loops to validate input