Added lastPage variable and changed first history variable to a string