Implementation of Dan's algorithm: starting to derive using structure.