changed scope of partition function from header file to local function