change order of vars so that calculations work