added more encoding/decoding methods