Lawmakers helped flip gambling bill from failure to passage