Onresume function and proper contexts