updated groovy script for anomaly detection