add validation (not a solid code, need to refactor)