fixed a bug with comma-separated tags and trailing comma