Added more variables and a structure for the decision function