added validation to inputs