update code add validation