fix alignment calculation