Andrei's refactoring