added avg option to query