Fixing index out of range error in the pool.