added validation and unit tests