Tried to break the query into parts but still the problem persists as the execution is happening concurrently. This is resulting in the done block of code in the parse query to not execute in the sequence of the code. Thus, the results queried are not available to use in the next computations. This is giving divide by zero exception.