Moved query library to the top