added encoder in code