CHANGED:applied the reorder reports function,clean up code