Adding auditing logic and permission checking