Added output file option
Added threshold option