adding encoder functionality