new morse algorithm