fixed bugs in order