added additional security checks around accessing activity.