full version before refactoring