Replaced switch statement as suggested in #10.