add random position generator and refactor
~~~