added Bats diag function