updated to handle an exception I'm causing by looking for a lastval()