Refactored the methods to use a map of functions over a switch statement