fixed errors when restarting app