Fixed bug with sql generation in available_tags method