fixed a bug in ordering