Maybe would be a good idea to check here if the PID exists, just to avoid this error:

```
[*] Preparing 'windows/meterpreter/reverse_tcp' for PID 31337
[*] Opening process 31337
[-] Unable to inject payload:
stdapi_sys_process_attach: Operation failed: The parameter is incorrect.
```