Refactor switch branches action