cramer's refactoring