added validation middleware