More precise detection of the command we have to store result

Avoiding race conditions