updated program to remember and compare last reading for increased accuracy