refactor backend switch