Parameterizing main algorithm.