Coin toss improvements

changed the coin toss into a function.