added history fn, error checking