improve code order