bug fixing to remove legacy code that checks the index against the count of layers which breaks the use of the tag as the index reference.