corrected main bug