Refactorization by @vjt