encodeUsingMap method