Refactor master command a little bit