perfect refactorization