modified encode