Added threshold_length to scanning functions