Adding encode / decode methods