Shouldn't this WHERE be changed to ```b.state IN ('confirmed', 'waiting_confirmation')``` ?