betting algorithm done