fixed onpause/onresume behavior