fixed handling of tags