Refactor and switch