TEMP: Bengt's algorithm seems to be working