#12 moved alignment code to run only once