refactor as reviews from @mesutcelik for issue #3458