Remove print intermediate results. Add check for missing values. Add fix to avoid overwrite prior values according to Daniel implementation.