reordered and simplified