Minor simplification
onpause and onresume changed just in case