moved key output to main.c, caught some bugs