add check for div visibility in the callfn loop