Refactor middleware. Add new string middleware