Calculate height dynamically