improve get_history (clearer + better error checking)