make variable names more appropriate, add comments