Add comments for history expansion function