moved some stuff out of game function