Moved diameter calculation into scope