Fixed the input checking