refactoring for database and user class