Added switching logic.