changed some variable names to make clear their purpose