added a proper assert function and moved around on the updateflag function to match that in the stable branch