Bug fix for first/last result