Added extra functionality to tags parsing to check for corner cases