Added main function and wrapped everything in it.