change encode and decode to async calls using blocks