toArray and divide by zero check