implemented and tested encoder