add logging code