fixing undefined error
adding aggregation queries