refactoring for multiuser support