Refactor and add function of restriction of commands