Updated check on history.length