Algorithm works.