Refactored the logic which is executes the commands and validations