transform algorithm and tests