Improved isValidSqrInput