Refactor radius calculation