added validation and tests