Internal refactor if command, define function command