The problem is your "or" condition. This should be an "and". The way your condition reads now, in basic english, is "while base is not -1 or height is not -1" so it evaluates, base is -1, but height...