try encoding for scala