check input validity