Added some code for the main function.