this also needs a better name (both variable and stateid)