added max height detection