Basic algorithm in place