initial working version of restrend