moved some stuff to a switch statement