Added counter to only save every nth query, Added create and append function for the query log