moved logic from oncreate to onresume