moved function outside main
made a diagonal set function