tweaked the select query on categories