align algorithm