fixed the initial code
simplified the code in align.py
merged align.py from new branch