a better mapping-based approach