added middleware to public API