changes the random values to keep it within the right range