tweaked encode