add @private annotations, factor out private function