I adopted some part of my patch, and make function name and docstring more clear after this mail thread long discussion.