Move lookup_previous to utility module