Added threshold scaling