fixed while looping in main