Improved code to predict all policies