created readVal function