mod cnvrgnc criteria & added regularizatn in error func