Refactor/threshold analysis