bunch of code to connect to the library