added improved height check