First implementation for #131

Heads Up: this may take a few iterations to get correct.