move code setting output parameters after possible failure