This could be simplified a bit by factoring the backend check out of all the ifs.