Add combination algorithm.
Simplify function.