add validation from previous code