add middleware for validating