added hash training algorithm