Wiktionary
mend one's ways
vb. (context idiomatic English) To recognise one's failings and attempt to remedy them