Change the var to val, and add logging (remove the TODO).