Out algorigtm done, but it seems that it's wrong