added getHeadOfLoop