Unforseen bug in main