added order() and fixed bugs