I would like to simplify this code by removing all those switch case with (which make this look very bulky and I would like to condense this if at all possible), a single functi