Split into functions, uses  and can change the lines threshold