Continuing work on javascript solution