Reimplementation of Tom Kelly and Peter Wonka work