add comment at encode function