fixing random logic