fix 'to' cannot be NA ... error