refactoring, use map