reorder and cleanup