fix cleanup nonces function