Gem switching logic (not finished).