Abstracted out the game loop (still needs testing)