move alignment training to a separate function