fixing to use data instead of calculating query apram