autopair again and small changes

and a function that might not work.