pretty much done and would work if i use forloop instead of apply(data, 1, checkExtreme)