Shortest cycle in undirected graph

src 1
/
2 3
/ \ /
4 5
consider this graph. if we are at node 5 neibours of 5 are 2,3. now if we see else if condition dis[nbr] >=dis[cur] this condition fails for node 3 since dis[nbr] = 1 and dis[cur]=2
but node 3 and 5 have backedge why condition is failing here but code works fine with this condition.Am I missing something?Please correct me.