Improve aspect ratio calculation