updated WLMC with parameter for the flatness gradient treshold