changed if chain to switch