fixed bug with onDisconnect and onMainPage event