Updated formula to correctly reference each index correctly.