Implementing the @yaneq6 solution for #82