Horizontal cost algorithm in progress.