encode is done, but not working!