modefied enconder.c