Complete rewrite of code

Made it random