changed to work with ted but some errors