Changed variable names and reformatted ifs