refactored constructor into switch statement