@sathify has a similar method in his PR.