Modified to properly retrieve the max results