It's in the patch if gave to you.
Of course your code works, but this can be handled by other functions to simplify things.