Made the KassamTrefethen method into a function