more realiable way to avoid flicking between pages