refactored middleware settings