finished alignemnt function