use curryable
use an iterative algorithm
docs