fixed a bug where onVisible would be called to often