More refactoring: simplified enter check and shortened correct place check.
Improved code for random number generation.