Algorithm started, not finished, but working so far