wrote 2 functions: findVal and findMeanVar