Added switch case very long function for saving and overwriting