Implemented changes to the way methods are composed, now the algorithm
works with more complicated functions.