added optimization based alignment -- seems to work