move determine run order to a method