Refactored getPartition() to get consistent pattern matching style