Function to process sources
Initial code for Segment class