better alignment algorithm