Slight refactor on switchDb