fixed WAIC function