Add height check algorithm