Refactor, and adding switch