Generic solution to #61