remove useless encoding and optimize code