encode and decode pass