Add copiright and use switch instead of if