Maybe this should be returned from the function instead of hiding it in internal variable.