ENH: Refactored this method as suggested by @pv.