mixed-up variable names corrected