Added an option to specify to order of decomposition in the decompose function