how would you write the following code:

```
if(Conditon 1){
            # code block 1...

            // another if condition
            if($device!=null){
                # code block 2...
            }else{
                # <code block X>
            }
}else{
            # <code block X>
}

```

So here `# <code block X>` is same at two places, how can I eliminate the redundancy?