renamed working variables, fixed capitalization bug