Fix bug in auditing function