Refactor NetworkEncoder