backwards inference, then some hacks to make it work