if not done then

if(q != rightpointer)