Changed setEncoding check to check type instead of null value