added impersonation and security checks