instagram middleware implementation