decode and encode