Rewrite a loop about checking player's input