added external encoder funntionality