Solving problem with ordering