Adding stack middleware