middleware to error check parameters