created removeSubMedian helper function and added it to processSpace