creates callback for query loaded