fixed the code to utilize ted's new function