Fix history lookup based on empty input