corrected confusing variable name and other tweaks