fix scope issue and add documentation comment