player creation moved to a new function