Moved code from onstart to onresume