Extracted Separation code to its own function