#29: introduce a function for the height calculation