add testing and changes in the main function