added validation methods and fixed match function