Automatically aligning the laser beam