Refactorings to reduce the number of nests and condition
about command attributes' key names