implement objects encode
fix objects encode