Reorder function in code