Add function for query