change check for encode!