changed some variables to auto for the compiler to infer their types