Fixed ValueError bug with randrange