rewrite validation and tests