Made some code refactoring procedure