Removed needless for loop

removed needless for loop in isValidInput and replaced with
string.split()