move lastvalues code into seperate block