improved prediction logic