Height finding function