Modified to also output tags