Moved function of input validation