replaced global var libID with reference to the library passed in