strange bug from main function