adding a recursive function to do the order of operations