Fixed a bug in main