https://papers.ssrn.com/sol3/Delivery.cfm/SSRN_ID3808657_code1924589.pdf?abstractid=3808657&mirid=1&type=2