refactorized (again)