check if beforeState exists before setting it's value
v0.2.3