Pasha's refactoring