Move lookup logic to context