added threshold from pr by @theluk