updated query to dynamically pull cat id