moved some switch statements around