i see. i think it was my getch()'s terminal settings causing the hanging
somehow. not really sure. Anyways, it works now.