Extracted switch statement to its own method