Amended main function