added comparison to avoid errors if a number is greater than the other