code tidy and reorder