reordered the original code