replaced getchar() with cin.get()