Refactored function determining validity of input data.