added check to see whether number entered is valid