See github.com/mconlon17 for code