Fixing loop in diagram tab