Jeremy Newman : move functions only used here from global