refactoring: extracted middleware
updated README