change the order of encoder and env