Improve the code using equal_range().