updated addUsage function to create middleware