Basic algorithm and program stub