changed threshold for failure and seperated from logic