implemented basic loop guard counter to prevent infinite loop pathways being created