Fixing crud middleware bug