refactoring by Dima