first complete algo