simplifyed encode and decode implemented