Initial implementation of encoder