Remove duplication.
Merge pull request #214 from miry/removed_duplication

Removed duplication in middleware