Adds loc safety check to set state.