Implemented queryFirst() function