Okay, basic algorithm is down