ouer main function:nedds to be refactored