mongoose refactor