clean up code in querying library