Revised version with shorter variable names.