segmented using functions: getting ready for multithreaded execution