refactor betting logic