added validation of input