Make algorithm a little clearer