Improved the way to set the IPrincipal