how to write a simple segmented control