refactoring for pseudo