Refactor order computing
Print the order for debug purposes
Lower first / last values to avoid overflow